package com.qf.blog.core.utils;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidDataSourceFactory;

import java.util.Properties;

/**
 * druid自动加载配置文件连接池工具类
 * @version 1.0
 * @auth zyt
 */
public class DruidTool2 {
    /**
     * 声明druid连接池
     */
    public static DruidDataSource dataSource=null;

    /**
     * 配置文件对象
     */
    public static Properties p=new Properties();

    static {
        try {
            //加载配置文件对象
            p.load(DruidTool2.class.getClassLoader().getResourceAsStream("jdbc.properties"));
            //获得连接池
            dataSource= (DruidDataSource) DruidDataSourceFactory.createDataSource(p);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

